package com.pactera.asmp.server.restfullapi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pactera.asmp.server.schedule.DeviceSchedule;
import com.pactera.asmp.server.schedule.ProjectSchedule;
import com.pactera.asmp.server.schedule.ScriptSchedule;
import com.pactera.asmp.server.schedule.TaskSchedule;

@RestController
@RequestMapping("/schedule")
public class RestfulScheduleApi {

    @Autowired
    private DeviceSchedule deviceSchedule;

    @Autowired
    private ProjectSchedule projectSchedule;

    @Autowired
    private ScriptSchedule scriptSchedule;

    @Autowired
    private TaskSchedule taskSchedule;

    @PostMapping(value = "/calculate", produces = "application/json;charset=UTF-8")
    public void calculate() {
        deviceSchedule.calculateDeviceUsedTime();
        deviceSchedule.calculateDeviceUsedTimeByNight();
        deviceSchedule.calculateLastMonthIncreaseRate();
        deviceSchedule.calculateSaveTimeByMonth();
        projectSchedule.calculateProjectTime();
        projectSchedule.calculateUserSpreadByProject();
        scriptSchedule.calculateScriptTime();
        taskSchedule.calculateLastMonthSuccessRate();
        taskSchedule.calculateTaskExceTime();
    }

}
